#include <iostream>
using namespace std;

/*
    【题目205】假设图书馆的图书包含书名、编号和作者三个属性，
    读者包含姓名和借书证属性，每位读者最多可借5本书，编写一个C++程序列出某读者的借书情况。
*/

class Book
{
public:
    Book(string bookName, int no,string author)
    {
        this->bookName = bookName;
        this->no = no;
        this->author = author;
    }
    Book()
    {}
    void show()
    {
        cout << "图书名称：" << this->bookName << endl;
        cout << "图书编号：" << this->no << endl;
        cout << "作者：" << this->author << endl;
    }
    void setBook(string bookName, int no,string author)
    {
        this->bookName = bookName;
        this->no = no;
        this->author = author;
    }

private:
    string bookName;
    int no;
    string author;

};
class Reader
{
public:
    Reader(string name, int number = 0)
    {
        this->readerName = name;
        this->number = number;
    }
    void rentBook(Book &b)
    {
        if (this->number < 5)
        {
            book[this->number]=b;
            this->number++;
        }
        else
        {
            cout << "您只能借五本书" << endl;
        }
    }
    void showAllBook()
    {
        cout << "读者名称：" << readerName << endl;
        cout << "借书数量：" << number << endl;
        for (int i = 0; i < number; i++)
        {
            cout << "第" << i + 1 << "本书：" << endl;
            book[i].show();
        }
    }

private:
    string readerName;
    int number;
    Book book[5];

};

int main()
{
    Book book1("AAA", 1, "张三");
    Book book2("AAA", 2, "张三");
    Book book3("AAA", 3, "张三");
    Book book4("AAA", 4, "张三");
    Book book5("AAA", 5, "张三");
    Book book6("AAA", 6, "张三");

    

    Reader reader("张三");
    reader.rentBook(book1);
    reader.rentBook(book2);
    reader.rentBook(book3);
    reader.rentBook(book4);
    reader.rentBook(book5);
    reader.rentBook(book6);

    reader.showAllBook();

    return 0;
}